<template>
    <div>
        <nav>
            <poifdx :pricedata="pricedata" />
            <pity :numberdata="numberdata" />
        </nav>
        <heade @searchteacher="searchteachers" @addvisual="addvisual" />
        <bood :list='list' :arr="arr" @refrsh="refrsh" @refrsharr="refrsharr" @updatevisual="updatevisual" />
        <foote :currentPage="currentPage" :pagesize="pagesize" :pagesizes="pagesizes" :total="total"
            @refpagesize="refpagesize" @refpagecurrent="refpagecurrent" />
        <pagec :tit="tit" :row="row" v-if="show" @getnum="getnum" @changeshow="changeshow" />
    </div>
</template>

<script>
    import poifdx from "./components/typicrure.vue"
    import pity from "./components/pity.vue"
    import heade from "./components/cheader.vue"
    import bood from "./components/cbody.vue"
    import foote from "./components/cfooter.vue"
    import pagec from "./components/pagechange.vue"
    import {
        chenqgetall,
        searchteacher,
        chenqgetshujushitu
    } from "../../api/interface.js"
    export default {
        components: {
            heade,
            bood,
            foote,
            pagec,
            poifdx,
            pity
        },
        data() {
            return {
                numberdata: '',
                pricedata: "",
                row: {},
                show: false,
                currentPage: 1,
                total: 100,
                tit: 0,
                pagesizes: [20, 50, 70, 100],
                pagesize: 20,
                arr: [],
                list: []
            }
        },
        created() {
            this.getnum();
        },
        methods: {
            addvisual() {
                this.tit = 0;
                this.show = true;
            },
            updatevisual(row) {
                this.row = row;
                this.tit = 1;
                this.show = true;
            },
            changeshow() {
                this.show = false;
                this.getnum();
            },
            getnum() {
                chenqgetall({
                    currentPage: this.currentPage,
                    pagesize: this.pagesize
                }).then(res => {
                    if (res.code == 200) {
                        this.list = res.data;
                        this.total = res.total
                        chenqgetshujushitu().then(res => {
                            this.numberdata = res.numberdata;
                            this.pricedata = res.pricedata;
                        })
                    }
                });

            },
            refpagesize(val) {
                this.pagesize = val;
                this.getnum();
            },
            refpagecurrent(val) {
                this.currentPage = val;
                this.getnum();
            },
            refrsh(res) {
                this.list = res;
                this.getnum();
            },
            refrsharr(res) {
                this.arr = res
            },
            searchteachers(val) {
                searchteacher({
                    id: val
                }).then(res => {
                    if (res.code == 200) {
                        this.refrsharr(res.data)
                    }
                })
            }
        }
    }
</script>

<style scoped>
    nav {
        display: flex;
        justify-content: space-evenly;
    }
</style>